home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / fax / faxdevice.py < prev    next >
Text File  |  2009-10-09  |  2KB  |  59 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2003-2008 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Local
  23. from base.g import *
  24. from prnt import cups
  25. from base import device, codes
  26. from soapfax import SOAPFaxDevice
  27. from pmlfax import PMLFaxDevice
  28.  
  29. def FaxDevice(device_uri=None, printer_name=None,
  30.               callback=None, 
  31.               fax_type=FAX_TYPE_NONE,
  32.               disable_dbus=False):
  33.                  
  34.     if fax_type == FAX_TYPE_NONE:
  35.         if device_uri is None and printer_name is not None:
  36.             printers = cups.getPrinters()
  37.     
  38.             for p in printers:
  39.                 if p.name.lower() == printer_name.lower():
  40.                     device_uri = p.device_uri
  41.                     break
  42.             else:
  43.                 raise Error(ERROR_DEVICE_NOT_FOUND)
  44.                 
  45.         if device_uri is not None:
  46.             mq = device.queryModelByURI(device_uri)
  47.             fax_type = mq['fax-type']
  48.             
  49.     log.debug("fax-type=%d" % fax_type)
  50.                     
  51.     if fax_type in (FAX_TYPE_BLACK_SEND_EARLY_OPEN, FAX_TYPE_BLACK_SEND_LATE_OPEN):
  52.         return PMLFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
  53.  
  54.     elif fax_type == FAX_TYPE_SOAP:
  55.         return SOAPFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
  56.  
  57.     else:
  58.         raise Error(ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATION)
  59.